
#ifndef _NUCDS_CODI_H_
#define _NUCDS_CODI_H_

#include "Tuna.hpp"
#include "Equations/ScalarEquation.hpp"

namespace Tuna {

  template <typename T, int Dim> class NUCDS_CoDi;

  template <typename T>
  struct Typeinfo <NUCDS_CoDi<T, 1> > {
    typedef T prec_t;
    enum { Dim = 1 };
  };

  template <typename T>
  struct Typeinfo <NUCDS_CoDi<T, 2> > {
    typedef T prec_t;
    enum { Dim = 2 };
  };

  template <typename T>
  struct Typeinfo <NUCDS_CoDi<T, 3> > {
    typedef T prec_t;
    enum { Dim = 3 };
  };

/*! 
 ***************************************************************************
 * Adaptor for central differences for scalar equation.
 ***************************************************************************
 *  \author  Luis M. de la Cruz [ Thu Jun 17 11:55:22 CDT 2010 ]
 ***************************************************************************
 */

template<typename Tprec, int Dim>
class NUCDS_CoDi : public ScalarEquation< NUCDS_CoDi< Tprec, Dim > >
{
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::aE;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::aW;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::aN;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::aS;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::aF;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::aB;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::aP;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::sp;
  //    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::dx;
  //    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::dy;
  //    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::dz;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::dxyz;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::dface;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::bi;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::ei;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::bj;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::ej;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::bk;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::ek;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::dt;    
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::applyBoundaryConditions1D;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::applyBoundaryConditions2D;
    using GeneralEquation<ScalarEquation<NUCDS_CoDi<Tprec, Dim > > >::applyBoundaryConditions3D;
       
    using ScalarEquation<NUCDS_CoDi<Tprec, Dim > >::Gamma;
    using ScalarEquation<NUCDS_CoDi<Tprec, Dim> >::phi_0;
    using ScalarEquation<NUCDS_CoDi<Tprec, Dim> >::u;
    using ScalarEquation<NUCDS_CoDi<Tprec, Dim> >::v;
    using ScalarEquation<NUCDS_CoDi<Tprec, Dim> >::w;

public:
  typedef Tprec prec_t;
  typedef typename TunaArray<prec_t, Dim >::huge ScalarField;

  NUCDS_CoDi() : ScalarEquation<NUCDS_CoDi<prec_t, Dim> >() { }
  ~NUCDS_CoDi() { }; 


  /*!
   * FVM coefficients calculations in 1D.
   */
  inline bool calcCoefficients1D(); 

  /*!
   * FVM coefficients calculations in 2D.
   */
  inline bool calcCoefficients2D();

  /*!
   * FVM coefficients calculations in 3D.
   */
  inline bool calcCoefficients3D();

  inline void printInfo() { std::cout << " NUCDS_CoDi "; }
};

} // Tuna namespace

#include "../../src/Schemes/NUCDS_CoDi.cpp"

#endif //_NUCDS_CODI_H_
